<!-- 我的-->
<template>
	<div>
		<!-- <uni-nav-bar title="我的"></uni-nav-bar> -->
		
		<div class="myAll">
			<image src="../../static/me_dlzp_img.png" style="width: 116upx; height: 116upx;border-radius: 50%;" mode=""></image>
			<p class="username">{{userName}}</p>
			<div class="optionList">
				<div class="ol ol1" @click="resetPsw">
					<image src="../../static/me_czmm_icon.png" style="width:40upx;height:40upx;" mode=""></image>
					<div class="optionsR">
						<p class="selectName">{{inter.czmm}}</p>
						<image class="rightIcon" src="../../static/grxx_more2_icon.png" style="width:32upx;height:36upx;" mode=""></image>
					</div>
				</div>
				<div class="ol" @click="updateClick">
					<image src="../../static/banbenhao.png" style="width:40upx;height:40upx;" mode=""></image>
					<div class="optionsR">
						<p class="selectName">{{inter.versionupdate}}</p>
						<view class="version-right">
							<text>V1.0.2</text>
						</view>
					</div>
				</div>
				<button type="primary" class="logOutButton" @tap="logOut">{{inter.tcdl}}</button>
				
			</div>
		</div>
		<view class="dialogView" v-if="updateShow" > 
			<div class="dialogDiv" >
				<div class="dialogDivTop">
					<text class="dialogDivTopText">
						{{inter.versionupdate}}
					</text>
				</div>
				<div class="dialogDivCenter">
					<div class="dialogDivCenterTop">
						<div class="dialogDivCenterTopDiv">
							<text style="color: #2F2F2F; font-size: 28upx;">{{inter.version + '：V' + version}}</text>
							<text style="color: #2F2F2F; font-size: 28upx; margin-left: 70upx;">{{inter.size +'：'+ size}}</text>
						</div>
						<div class="dialogDivCenterTopDiv" style="margin-top: 10upx;">
							<text style="color: #2F2F2F; font-size: 28upx;">{{inter.time + '：'+time}}</text>
						</div>
					</div>
					<div class="dialogDivCenterBottom">
						<div class="dialogDivCenterTopDiv" >
							<text style="color: #4A86C6; font-size: 28upx;">{{inter.newfunction+':'}}</text>
						</div>
						<div class="dialogDivCenterTopDiv" >
							<text style="color: #2F2F2F; font-size: 28upx;">{{upLog}}</text>
						</div>
					</div>
				</div>
				<div style="background-color: #979797; width: 610upx; height: 2upx;"/>
				<div class="dialogDivBottom">
					<div class="dialogDivBottomLeft" v-if="forceUpdateShow" @click="cancleFun">
						<text class="dialogDivBottomLeftText">{{inter.updatelater}}</text>
					</div>
					<div style="width: 2upx;height: 100%;background-color: #979797;" v-if="forceUpdateShow"/>
					<div class="dialogDivBottomLeft" @click="sureUpdateClick">
						<text class="dialogDivBottomRightText">{{inter.updatenow}}</text>
					</div>
				</div>
			</div>
		</view>
	</div>
</template>

<script>
	import $api from '@/api/api.js';
	import $inter from '@/api/international.js'
	var pinf = plus.push.getClientInfo();
	function unBindCID(that){
		$api.unBindCID({
			CID:pinf.clientid
		},res=>{
			  console.log("111"+JSON.stringify(res));
			  $api.logOut(res=>{
			  	
			  	$api.idSetter('Authorization_Token','')
			  	$api.idSetter('password','')
			  	uni.showToast({
			  		title: that.inter.tccg,
			  		mask: false,
			  		icon:'success',
			  		duration: 1500
			  	});
			  	uni.reLaunch({
			  		url: '../login/login?loginout=1'
			  	});
			  	uni.hideToast()
			  },err=>{
			  	uni.showModal({
			  		content: err.errMsg,
			  		showCancel: false
			  	});
			  	uni.hideToast()
			  },e=>{
			  	
			  })	
		},err=>{
			uni.showToast({
				title:that.inter.dataFail,
				icon:'none',
				mask:true
			})
			console.log("222"+JSON.stringify(err));
		},e=>{
			
		})
	}
	
	export default {
		
		data(){
			return {
				languageValue:'',
				internatinal:'',
				"userName":'',
				updateShow: false,
				forceUpdateShow:true,
				pkgUrl:'',
				version:'',
				updateBaseURL:'',
				time: '',
				upLog:'',
				size:''
			}
		},
		onLoad() {
			uni.getStorage({
				key:'languageValue',
				success:(res)=>{
					this.languageValue = res.data
				}
			})
			uni.setNavigationBarTitle({
				title: this.inter.my
			});
			this.userName = uni.getStorageSync('userInfo').UserName
		},
		methods:{
			updateClick(){
				uni.showToast({
					title: 'loading',
					icon:'loading',
					mask:true,
				});
				uni.getStorage({
					key: 'baseURL',
					success: (res)=>{this.getUpdataApp(res.data)}
				});
			},
			cancleFun(){
				this.updateShow=false
			},
			sureUpdateClick(){
				this.updateShow = false 
				if(plus.os.name=="Android"){
					plus.runtime.openURL(this.updateBaseURL+this.pkgUrl);
				}else{
					plus.runtime.openURL(this.pkgUrl)
				}
			},
			getUpdataApp(baseURL){
				let len=baseURL.length;
				len=len-4;
				this.updateBaseURL = baseURL.substring(0,len)
				var PhoneType = plus.os.name
				if(PhoneType=="Android"){
					$api.getUpdataApp({
							PhoneType: PhoneType,
							Version: '1.0.2'
						}, res=>{
							this.version = res.Verison
							this.pkgUrl = res.pkgUrl
							this.time = res.UpdTime
							this.upLog = res.UpdLog
							this.size = res.FileSize
							if(res.update== 1 && res.forceUpdate == 0){
								this.forceUpdateShow = true
								this.updateShow = true
							}else if(res.update==1 && res.forceUpdate == 1){
								this.forceUpdateShow = false
								this.updateShow = true
							}else{
								uni.showModal({
									title: this.inter.versionupdate,
									content: this.inter.updateTips,
									showCancel: true,
									success: function (e) {
										if (e.confirm) {
											
										}
									}
								});
							}
							uni.hideToast()
						}, err=>{
							
						},(e)=>{
									
					})
				}else{
					plus.runtime.openURL('https://itunes.apple.com/us/app/dms%E6%95%B0%E5%AD%97%E5%88%B6%E9%80%A0%E7%B3%BB%E7%BB%9F-smx/id1462029113?mt=8&from=singlemessage&isappinstalled=0')
				}

			},
			logOut(){
				uni.showModal({
					title: this.inter.tcdl,
					content: this.inter.tccgTips,
					success: res => {
						if (res.confirm) {
							uni.showToast({
								title: 'loading',
								icon:'loading',
								mask:true,
							});
							unBindCID(this)
						} else if (res.cancel) {
							console.log('用户点击取消');
							
						}
						
					},
					fail: () => {},
					complete: () => {}
				});
			
			},
			resetPsw(){
				uni.navigateTo({
					url: 'resetPsw',
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		computed:{
			inter(){
				return $inter.my
			}
		}
	}
</script>

<style scoped>
	.myAll{
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-top: 106upx;
		
	}
	.username{
		font-size: 36upx;
		font-weight: 400;
		color: #5D5D5D;
		margin-top: 42upx;
	}
	.ol{
		width: 90vw;
		height: 98upx;
		display: flex;
		flex-direction: row;
		align-items: flex-end;
		justify-content: space-between;
		align-items: center;
		color: #5D5D5D;
		font-size: 28upx;
		background-color: #FFFFFF; 
		padding-left: 32upx;
		padding-right: 32upx;
		
	}
	.optionList{
		margin-top: 110upx;
	}
	.selectName{
		
		
	}
	.rightIcon{
		margin-left: 30upx;
	}
	.version-right{
		display: flex;
		flex-direction: row;
	}
	.optionsR{
		width: 92%;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}
	.ol1{
		border-bottom: 1upx solid #C8C7CC;
	}
	.ol3{
		margin-top: 16upx;
	}
	.logOutButton{
		background: -webkit-linear-gradient(left, #107FD2 , #06C9ED); /* Safari 5.1 - 6.0 */
		background: -o-linear-gradient(right, #107FD2, #06C9ED); /* Opera 11.1 - 12.0 */
		background: -moz-linear-gradient(right, #107FD2, #06C9ED); /* Firefox 3.6 - 15 */
		background: linear-gradient(to right, #107FD2 , #06C9ED); /* 标准的语法 */
		width: 596upx;
		height: 96upx;
		margin-top: 250upx;
		color: #ffffff;
		font-size: 32upx;
		text-align: center;
		line-height: 96upx;
	}
	.flend{
		/* width: 100%; */
		display: flex;
		flex-direction: row;
		justify-content: flex-end;
	}
	.dialogView{
		display: flex;
		justify-content: center;
		align-items: center;
		background-color:rgba(0,0,0,0.7);
		position: absolute;
		top: 0;
		left: 0;
		z-index:100;
		width: 100vw; 
		height: 100vh;
	}
	.dialogDiv{
		width: 610upx;
		height: 530upx;
		background-color: #F5F8FF;
		border-radius: 8upx;
		display: flex;
		flex-direction: column;
	}
	.dialogDivTop{
		width: 610upx;
		height: 100upx;
		display: flex;
		flex-direction: row;
		align-items: center;
		background: -webkit-linear-gradient(left, #107FD2 , #06C9ED); /* Safari 5.1 - 6.0 */
		background: -o-linear-gradient(right, #107FD2, #06C9ED); /* Opera 11.1 - 12.0 */
		background: -moz-linear-gradient(right, #107FD2, #06C9ED); /* Firefox 3.6 - 15 */
		background: linear-gradient(to right, #107FD2 , #06C9ED); /* 标准的语法 */
		border-top-right-radius: 8upx;
		border-top-left-radius: 8upx;
	}
	.dialogDivTopText{
		margin-left: 42upx;
		font-size: 28upx;
		color: #FFFFFF;
	}
	.dialogDivCenter{
		width: 610upx;
		height: 100%;
	}
	.dialogDivBottom{
		width: 610upx;
		height: 120upx;
		display: flex;
		flex-direction: row;

	}
	.dialogDivBottomLeft{
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		
	}
	.dialogDivBottomLeftText{
		color: #9B9B9B;
		font-size: 28upx;
	}
	.dialogDivBottomRightText{
		color: #4A86C6;
		font-size: 28upx;
	}
	.dialogDivCenterTop{
		width: 536upx;
		height: 140upx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		
	}
	.dialogDivCenterTopDiv{
		margin-left: 42upx;
	}
	.dialogDivCenterBottom{
		width: 536upx;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
	}
</style>
